-
Notifications
You must be signed in to change notification settings - Fork 587
Fix finding the correct cplusplus compiler #23146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ExtUtils::CBuilder was using a slightly maverick method for finding the matching cplusplus compiler to the c compiler used to build perl. On a Linux system with a perl built with the Oracle Developer cc cc='/opt/oracle/developerstudio12.6/bin/cc' Errors were observed: "c++: error: unrecognized command line option ‘-KPIC’; did you mean ‘-fPIC’?" The cplusplus command for Oracle Developer suite is CC not c++ and the detection was picking up the system c++ (g++). If there is a ccpath, the code should exhaust all the options and not fail through to using no path.
Are there any changes that could be added to CBuilder's test suite that would exercise these code changes? |
if( can_run( $cxx1 ) ) { | ||
$self->{config}{cxx} = $cxx1; | ||
last; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation here doesn't match the rest of the file, and has added literal tabs mixed with the spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't actually change that from the original, the literal tab was there before. But let me fix that.
The test t/03-cpluscplus.t was the test that highlighted to me that the detection behaviour was wrong. |
The following patch would test and detect the bad detection logic on common platforms, I believe: --- dist/ExtUtils-CBuilder/t/03-cplusplus.t
+++ dist/ExtUtils-CBuilder/t/03-cplusplus.t
@@ -26,7 +26,18 @@ else {
plan tests => 7;
}
-ok $b, "created EU::CB object";
+{
+ # GH #23146
+ my $fake_cc = File::Spec->rel2abs(File::Spec->catfile(qw(some directory what doesnt exist), 'cc'));
+ my $b = ExtUtils::CBuilder->new(
+ quiet => $quiet,
+ config => {
+ cc => $fake_cc,
+ },
+ );
+
+ is $b->{config}{cxx}, $fake_cc, "did not search PATH for C++ compiler when given absolute path to C compiler";
+}
ok $b->have_cplusplus, "have_cplusplus";
(I removed the |
I checked-out this p.r. locally, applied @mauke's patch, and hacked up CBuilder/Base.pm with some debugging statements. (See: https://github.com/Perl/perl5/tree/jkeenan/pr23146-with-mauke-patch-20250419.) On that basis, I believe @mauke's patch would do what he claims it would; hence, it should be applied to the p.r. and the p.r. to blead -- unless @bingos objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add @mauke's patch to test file; then okay to merge.
@bingos Speaking for the PSC, we’d like to ship this. Can you get to it? |
I have no objections. |
Added the test should be good to rebase and merge once the checks are done. |
This p.r. is repeatedly failing one test file on 2 Windows runs in our GH CI. See, e.g.,
We can use someone with access to Windows to debug this. |
I've messed up the tests, I'll fix that. I have a Windows Server 2019 virtual host with Visual Studio Enterprise 2019 installed so I am running a build/test of the branch on there. |
I am not entirely sure why but the test added to exercise ccpath is the cause of the problems on Windows with MSVC. The test uses 'cc' as the compiler which makes EUCB believe that it is now using GCC rather than MSVC and sets all the flags for compiling and linking to GCC If I move that test to the end everything is good. |
Merged as ea0856c |
ExtUtils::CBuilder was using a slightly maverick method for finding the matching cplusplus compiler to the c compiler used to build perl.
On a Linux system with a perl built with the Oracle Developer cc cc='/opt/oracle/developerstudio12.6/bin/cc'
Errors were observed:
"c++: error: unrecognized command line option ‘-KPIC’; did you mean ‘-fPIC’?"
The cplusplus command for Oracle Developer suite is CC not c++ and the detection was picking up the system c++ (g++).
If there is a ccpath, the code should exhaust all the options and not fail through to using no path.
Clang/Clang++ were missing from the C/C++ mappings so I have added those as well.